package com.biz.primus.model.sso.account.vo;

import com.biz.primus.base.enums.CommonStatus;
import com.biz.primus.model.sso.auth.vo.MenuGroupVO;
import com.biz.primus.model.sso.auth.vo.UserAuthority;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * Created by younger on 17/11/1.
 */
@Data
public class UserVo implements Serializable,UserDetails {
    private static final long serialVersionUID = -1501206026311154899L;

    private String id;
    private String username;
    private String password;
    private String name;
    private String phone;
    private String empNo;
    private CommonStatus status = CommonStatus.ENABLE;
    private Date createDate;
    private String createBy;

    private List<MenuGroupVO> menuGroups;

    private Set<UserAuthority> authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return this.status.isEnable();
    }
}
